import os
import yagmail as ym
import cfg

mail_cfg = cfg.config("mail")


def create_email(subject, content, files: list):
    # 输入发件人昵称、收件人昵称、主题，正文，附件地址,附件名称生成一封邮件
    # 读取配置文件发送邮件
    if mail_cfg["on_off"] in (0, "off"):
        return
    mail = ym.SMTP(user=mail_cfg["user"], password=mail_cfg["password"], host=mail_cfg["host"])
    mail.send(to=mail_cfg["to"].split(';'), subject=subject, contents=content, attachments=files)


if __name__ == '__main__':
    pass
